package com.example.demo.controller;

import com.example.demo.service.AttendanceService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RestController;
import org.springframework.web.multipart.MultipartFile;

import javax.servlet.http.HttpServletResponse;
import java.io.IOException;
import java.util.Arrays;

/**
 * @author DUYULONG
 * @date 2023/11/22 15:10
 */
@RestController
public class AttendanceController {

    @Autowired
    private AttendanceService attendanceService;

    /**
     * 根据时间筛选考勤记录
     * @param file
     * @param startTime
     * @param endTime
     * @throws IOException
     * @throws InterruptedException
     */
    @PostMapping("/attendance/excel")
    public void excel(MultipartFile file, String startTime, String endTime, String userList) throws IOException, InterruptedException {
        String[] split = userList.split(",");
        attendanceService.excel(file, startTime, endTime, Arrays.asList(split));
    }

    @PostMapping("/attendance/word")
    public String word(MultipartFile word, MultipartFile excel, String folder) throws IOException {
        attendanceService.word(word, excel, folder);
        return "SUCCESS";
    }
}
